using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Media;

using NewtonDynamics;

namespace WPFPhysics1
{
	public class Tire : INotifyPropertyChanged
	{
		private CTire tire;
		private double diameter;
		private Vector offset;

		/// <summary>
		/// Create a new Tire instance
		/// </summary>
		/// <param name="diameter">Tire diameter</param>
		/// <param name="tire">NewtonDynamics tire</param>
		public Tire( double diameter, CTire tire )
		{
			this.tire = tire;
			this.diameter = diameter;
			offset = new Vector( -diameter / 2, -diameter / 2 );
		}

		/// <summary>
		/// Notify matrix changed
		/// </summary>
		public void Update()
		{
			if ( PropertyChanged != null ) PropertyChanged( this, new PropertyChangedEventArgs( "DisplayMatrix" ) );
		}

		/// <summary>
		/// Get diameter
		/// </summary>
		public double Diameter { get { return diameter; } }

		/// <summary>
		/// Get display matrix
		/// </summary>
		public Matrix DisplayMatrix { get { return Body.GetDisplayMatrix( tire.Matrix, offset ); } }

		#region INotifyPropertyChanged Members

		public event PropertyChangedEventHandler PropertyChanged;

		#endregion
	}
}